#include <stdio.h>
#include <string.h>

long MyStrLen(const char *s)
{
    long len = 0;
    while(*s++ != '\0')
        len++;
        //s++;
        return len;
}

int MyStrcmp(const char *s1, const char *s2)
{
    
   
    while( *s1 == *s2 && *s1 != '\0' && *s2 != '\0')
    {
        s1++;
        s2++;
    }
    return *s1 - *s2;
}
void MyStrcpy(char *dest, const char* src)//int n是只拷贝n个
{
    while(*src != '\0')
    {
        
        *dest++ = *src++;
        *dest = '\0';
    }
}

void MyStrcat(char *dest, const char *src)
{
    while(*dest != '\0')
    dest++;
    //调用已有接口
    MyStrcat(dest,src);
}

char *MyStrstr(const char* const dest, const char *src)
{
    long dlen = strlen(dest);
    long slen = strlen(src);
    for(int i = 0; i <= dlen - slen; i++)
    {
        if(strncmp(dest + i,src,slen) == 0)
        {
            return (char *)(dest +i);
        }
    }
    return NULL;
}
char *MyStrtok(char *src,const char *delim)
{
    static char *dest = NULL;
    if(src != NULL)
    {
        dest = strstr(src,delim);
        //没有找到匹配的子字符串
        if(dest == NULL)
        {
            return src;
        }
        *dest = '\0';
        dest = dest + strlen(delim);
        return src;
    }
    else
    {
        if(dest == NULL)
        {
            return NULL;
        }
        char *nextDest = strstr(src,delim);
        char *header = dest;
        if(nextDest == NULL)
        {
            dest = NULL;
            return header;
        }
        *nextDest = '\0';
        dest = nextDest + strlen(delim);
        return header;
    }
    char *dest = strstr(src,delim);
    //没有找到匹配的子字符串
    if(dest == NULL)


}

int main()
{
    char s1[10] = "helloworld";
    char *s2 = "hello";
    MyStrcpy(s1, s2);
    printf("%s\n", s1);

    return 0;
}
